// 聊天互动
const chatMixin = {
	data(){
		return{
			chatList: [],
		}
	},
	methods: {
		// 接收推送的聊天数据
		appendChatList(data){
			data.dataList.map(item=>{
				if(item.userId == this.clientUserId){
					item.position = 'right';
				}else{
					item.position = 'left';
				}
			})
			this.chatList = [...this.chatList, ...data.dataList];
			this.goBottom(); // scroll置底
		},
		// 发送消息
		send_comment(message) {
			this.socket.sendSocketMessage('0001', {
				Id: this.Id,
				ClassId: this.classId,
				NickName: this.clientUserName,
				Content: message.content,
				UserId: this.clientUserId
			}).then(resp=>{
				this.init_input();
			})
		}
	}
}

export default chatMixin;